home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Mobiles Büro / Newton / Newton Entwickler / DIL 2.0 Mac OS ƒ / Headers / DIL.h < prev    next >
Text File  |  1997-09-19  |  4KB  |  139 lines

  1. /*
  2.     File:        DIL.h, v2.0a2
  3.  
  4.     Contains:    Public interface to the Desktop Integration Library
  5.  
  6.     Copyright:    Apple Computer, Inc. 1997, all rights reserved.
  7. */
  8.  
  9. #ifndef __DIL_H
  10. #define __DIL_H
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15.  
  16. #if defined(_WIN32) && defined(macintosh)
  17.     #error Please define only one of _WIN32 or macintosh
  18. #endif
  19.  
  20. #if !defined(_WIN32) && !defined(macintosh)
  21.     #error Please define either _WIN32 or macintosh
  22. #endif
  23.  
  24. #ifdef _WIN32
  25.     #define DIL_HasByteSwapping    1
  26.  
  27.     #define DECLSPEC_EXPORT __declspec(dllexport)
  28.     #define DECLSPEC_IMPORT __declspec(dllimport)
  29.  
  30.     #if defined(BUILDING_DIL)
  31.         #define DILAPI DECLSPEC_EXPORT
  32.     #else
  33.         #define DILAPI DECLSPEC_IMPORT
  34.     #endif
  35. #else
  36.     #define DILAPI
  37. #endif
  38.  
  39.  
  40. #define DECLARE_DIL_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  41.  
  42.  
  43. typedef unsigned short    DIL_WideChar;
  44. typedef long            DIL_Error;
  45.  
  46.  
  47. #define kDIL_NoError                    (0)
  48. #define kDIL_ErrorBase                    (-98000)
  49.  
  50.  
  51. /* --- General DIL errors --- */
  52.  
  53. #define kDIL_OutOfMemory                (kDIL_ErrorBase - 1)
  54. #define kDIL_InvalidParameter            (kDIL_ErrorBase - 2)
  55. #define kDIL_InternalError                (kDIL_ErrorBase - 3)
  56. #define kDIL_ErrorReadingFromPipe        (kDIL_ErrorBase - 4)
  57. #define kDIL_ErrorWritingToPipe            (kDIL_ErrorBase - 5)
  58. #define kDIL_InvalidHandle                (kDIL_ErrorBase - 6)
  59.  
  60.  
  61. /* --- Base error numbers --- */
  62.  
  63. #define kCD_ErrorBase                    (kDIL_ErrorBase - 200)
  64. #define kFD_ErrorBase                    (kDIL_ErrorBase - 400)
  65. #define kPD_ErrorBase                    (kDIL_ErrorBase - 600)
  66.  
  67.  
  68. /*
  69. **    Procedures for providing data to or receiving data from the DILs. DIL_WriteProc
  70. **    should take the profferred amount of data and write it somewhere (to a file or
  71. **    memory buffer, perhaps). DIL_ReadProc should cough up the requested number of
  72. **    of bytes. If either function succeeds, it returns kDIL_NoError. If not, it
  73. **    returns some non-zero error number.
  74. */
  75.  
  76. typedef DIL_Error (*DIL_WriteProc)(const void* buf, long amt, void* userData);
  77. typedef DIL_Error (*DIL_ReadProc)(void* buf, long amt, void* userData);
  78.  
  79.  
  80. #ifdef __cplusplus
  81. }    /* extern "C" */
  82. #endif
  83.  
  84.  
  85. /*
  86. **    --------------------------------------------------------------------------------
  87. **        Byte swapping
  88. **    --------------------------------------------------------------------------------
  89. */
  90.  
  91. /* Watch out for these macros...they can silently turn your values into different types... */
  92.  
  93. #define DIL_BYTE_SWAP_8(n)    (n)
  94. #define DIL_BYTE_SWAP_16(n)    (((n >> 8) & 0x000000FF) | ((n << 8) & 0x0000FF00))
  95. #define DIL_BYTE_SWAP_32(n)    (((n << 24) & 0xFF000000) | ((n << 8) & 0x00FF0000) | ((n >> 8) & 0x0000FF00) | ((n >> 24) & 0x000000FF))
  96.  
  97. /*
  98. **    The following macros are for code with static data that
  99. **    assumes ordering different from native ordering
  100. */
  101.  
  102. #ifdef DIL_HasByteSwapping
  103.  
  104.     #define    DIL_CANONICAL_8(n)    DIL_BYTE_SWAP_8(n)
  105.     #define DIL_CANONICAL_16(n)    DIL_BYTE_SWAP_16(n)
  106.     #define DIL_CANONICAL_32(n)    DIL_BYTE_SWAP_32(n)
  107.  
  108. #else
  109.  
  110.     #define DIL_CANONICAL_8(n)    (n)
  111.     #define DIL_CANONICAL_16(n)    (n)
  112.     #define DIL_CANONICAL_32(n)    (n)
  113.  
  114. #endif
  115.  
  116. #ifdef __cplusplus
  117.  
  118.     inline signed char        DIL_ByteSwap(signed char n)        { return (signed char)        DIL_BYTE_SWAP_8(n); }
  119.     inline char                DIL_ByteSwap(char n)            { return (char)                DIL_BYTE_SWAP_8(n); }
  120.     inline unsigned char    DIL_ByteSwap(unsigned char n)    { return (unsigned char)    DIL_BYTE_SWAP_8(n); }
  121.     inline short            DIL_ByteSwap(short n)            { return (short)            DIL_BYTE_SWAP_16(n); }
  122.     inline unsigned short    DIL_ByteSwap(unsigned short n)    { return (unsigned short)    DIL_BYTE_SWAP_16(n); }
  123.     inline long                DIL_ByteSwap(long n)            { return (long)                DIL_BYTE_SWAP_32(n); }
  124.     inline unsigned long    DIL_ByteSwap(unsigned long n)    { return (unsigned long)    DIL_BYTE_SWAP_32(n); }
  125.  
  126.     inline signed char        DIL_Canonical(signed char n)    { return (signed char)        DIL_CANONICAL_8(n); }
  127.     inline char                DIL_Canonical(char n)            { return (char)                DIL_CANONICAL_8(n); }
  128.     inline unsigned char    DIL_Canonical(unsigned char n)    { return (unsigned char)    DIL_CANONICAL_8(n); }
  129.     inline short            DIL_Canonical(short n)            { return (short)            DIL_CANONICAL_16(n); }
  130.     inline unsigned short    DIL_Canonical(unsigned short n)    { return (unsigned short)    DIL_CANONICAL_16(n); }
  131.     inline long                DIL_Canonical(long n)            { return (long)                DIL_CANONICAL_32(n); }
  132.     inline unsigned long    DIL_Canonical(unsigned long n)    { return (unsigned long)    DIL_CANONICAL_32(n); }
  133.  
  134. #endif
  135.  
  136. #endif    /* __DIL_H */
  137.  
  138.  
  139.